from django.contrib import admin

from django import forms

from assets.models import *

admin.site.register(FormatType)
admin.site.register(Format)
admin.site.register(MetaData)


def Asset_transcode(modeladmin, request, queryset):
  from jobs.models import Job
  for object in queryset:
    j = Job.objects.create_job(object, 'transcode_cache')
    j.schedule()
    j.save()
Asset_transcode.short_description = "Transcode precache for selected assets"

class AssetAdmin(admin.ModelAdmin):
  actions = [Asset_transcode]
  list_display = ('id', 'subName', 'format',)
  #list_display_links = ('id', 'subName',)
  list_filter = ('format__type', )
  search_fields = ('id', 'subName', 'format__name', 'file__file_name',)
  raw_id_fields = ('file', 'dependencies',)

    

admin.site.register(Asset, AssetAdmin)





